package com.mdxq.springboot04_mybatis_plus.controller;
import com.mdxq.springboot04_mybatis_plus.entity.Person;
import com.mdxq.springboot04_mybatis_plus.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
public class PersonController {
    @Autowired
    private PersonService personService;

    @GetMapping("/person/queryAll")
    public List<Person> queryAll(){
        return personService.list();
    }
    @PostMapping("/person/save")
    public Boolean save(@RequestBody Person person){
        return personService.save(person);
    }

    @PostMapping("/person/edit")
    public Boolean edit(@RequestBody Person person){
        return personService.updateById(person);
    }
    @GetMapping("/person/remove/{id}")
    public Boolean remove(@PathVariable Integer id){
        return personService.removeById(id);
    }
    @GetMapping("/person/queryOne/{id}")
    public Person queryOne(@PathVariable Integer id){
        return personService.getById(id);
    }
}